package com.schooldate.model.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.schooldate.annotation.JsonIncludeField;
import com.schooldate.base.BaseVo;
import org.apache.struts2.json.annotations.JSON;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 学校信息
 * id 学校用2位或三位 专业用3位
 * name学校名字或者专业名字
 * Created by etund on 2015/3/9.
 */
@Entity
public class School extends BaseVo{

    @Id
//    @GeneratedValue(generator = "system-uuid")
//    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "id",length = 10)
    @GeneratedValue(strategy = GenerationType.AUTO)
    @JSONField(name = "schoolId")
    private int id;
    @Column
    private String sid;
    @Column
    private String   cid;
    @Column
    private String name;

    @OneToMany(fetch = FetchType.EAGER , cascade = CascadeType.ALL)
    @JoinColumn(name = "schoolInfoId")
    private Set<UserInfo> userInfos;

    @OneToMany(fetch = FetchType.EAGER , cascade = CascadeType.ALL)
    @JoinColumn(name = "schoolInfoId")
    private Set<ExamSource> examSources = new HashSet<ExamSource>();

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @JsonIncludeField(namespace = {"userInfo","index" ,"nearSchool.do"})
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Set<UserInfo> getUserInfos() {
        return userInfos;
    }

    public void setUserInfos(Set<UserInfo> userInfos) {
        this.userInfos = userInfos;
    }

    @JsonIncludeField(namespace = {"userInfo","index","nearSchool.do"})
    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    @JsonIncludeField(namespace = {"userInfo"})
    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }

    public Set<ExamSource> getExamSources() {
        return examSources;
    }

    public void setExamSources(Set<ExamSource> examSources) {
        this.examSources = examSources;
    }
}
